package com.hfut.se.zhisms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Telephony;

import com.hfut.se.zhisms.EnvironmentTools;

/**
 * Listens for incoming MMS messages.
 * <p/>
 * Created by lynn on 2015/11/9.
 */
public class MmsReceiver extends BroadcastReceiver {

    /**
     * Use this when SDK equal or higher than 19 (Android 4.4 or higher).
     */
    public final static String ACTION_DELIVER = Telephony.Sms.Intents.SMS_DELIVER_ACTION;

    /**
     * Use this when SDK lower than 19 (Android 4.3 or lower).
     */
    public final static String ACTION_RECEIVED = Telephony.Sms.Intents.SMS_RECEIVED_ACTION;

    @Override
    public void onReceive(Context context, Intent intent) {
        String action;
        if (EnvironmentTools.isKitkatOrHigher()) {
            action = ACTION_DELIVER;
        } else {
            action = ACTION_RECEIVED;
        }

        if (action.equals(intent.getAction())) {
            // Received a message.

        }
    }
}
